

function multi(n){
    var fn = function(x) {
        return multi(n * x);
    };
    fn.valueOf = function() {
        return n;
    };
    return fn;
}

console.log(multi(1)(2)(3)(4)(5).valueOf()) // 120